#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main()
{
    char file[32] = "/tmp/test.img";
    int fd = open(file, O_RDONLY);
    if (fd < 0)
    {
        perror("open");
        return -1;
    }

    char buf[4096];
    int len;
    int count = 0;
    while (1)
    {
        len = read(fd, buf, sizeof(buf));
        if (len <= 0)
            break;
        count ++;
        // printf("read %d bytes\n", len);
    }
    printf("read %d times\n", count);
}